
#include "StdAfx.h"
#include "myapp.h"
#include ".\mainwnd.h"

MSGMAP_ENTRY _messageEntriesMain[] =
{
	WM_INITDIALOG,OnInitDialog,
	WM_COMMAND,OnCommandMain,
};

CMDMAP_ENTRY _commandEntiresMain[] = 
{
	IDOK,OnOk,
	IDCANCEL,OnCancel,
//	IDC_BTNHELP,OnHelp,
};

TCHAR szCipherKey[BUFSIZ];

INT_PTR CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	for(int i=0;i<dim(_messageEntriesMain);i++)
	{
		if(msg == _messageEntriesMain[i].msg)
		{
			return (*_messageEntriesMain[i].pfn)(hWnd,wParam,lParam);
		}
	}
	return FALSE;
}

LRESULT OnCommandMain(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	for(int i=0;i<dim(_commandEntiresMain);i++)
	{
		if(LOWORD(wParam) == _commandEntiresMain[i].id)
		{
			return (*_commandEntiresMain[i].pfn)(hWnd,LOWORD(wParam),HIWORD(wParam),(HWND)lParam);
		}
	}

	return FALSE;
}

LRESULT OnInitDialog(HWND, WPARAM, LPARAM)
{
	return TRUE;
}

LRESULT OnOk(HWND hWnd, UINT, UINT, HWND)
{
	GetDlgItemText(hWnd,IDC_EDTKEY,szCipherKey,BUFSIZ);
	MessageBox(hWnd,szCipherKey,"Cipher Key",MB_OK | MB_ICONEXCLAMATION);
	return TRUE;
}

LRESULT OnCancel(HWND hWnd, UINT, UINT, HWND)
{
	DestroyWindow(GetParent(hWnd));
	return TRUE;
}

LRESULT OnHelp(HWND, UINT, UINT, HWND)
{
	//TestPE();
	return TRUE;
}


